package cn.enilu.guns.service.door;


import cn.enilu.guns.bean.entity.door.EquipmentInfo;
import cn.enilu.guns.bean.vo.query.SearchFilter;
import cn.enilu.guns.dao.door.EquipmentInfoRepository;

import cn.enilu.guns.service.BaseService;
import cn.enilu.guns.utils.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentInfoService extends BaseService<EquipmentInfo,Long,EquipmentInfoRepository>  {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private EquipmentInfoRepository equipmentInfoRepository;

    public boolean checkIpExist(EquipmentInfo equipmentInfo){
        List<SearchFilter> searchFilters = Lists.newArrayList();
        searchFilters.add(new SearchFilter("ipAddress",SearchFilter.Operator.EQ,equipmentInfo.getIpAddress()));
        List<EquipmentInfo> equipmentInfos = queryAll(searchFilters);
        if(equipmentInfos.size() > 0){
            return false;
        }
        return true;
    }

}

